Java kmeans基础算法kmeans begins
迭代次数=5
kmeans running time=0ms
kmeans ends
print:cluster[0][0]={5.0,6.0,7.0,6.0,7.0,0.0,0.0}
print:cluster[0][1]={8.0,9.0,10.0,6.0,7.0,0.0,0.0}
print:cluster[0][2]={3.0,9.0,6.0,6.0,7.0,0.0,0.0}
print:cluster[0][3]={5.0,9.0,14.0,6.0,7.0,0.0,0.0}
===================================
print:cluster[1][0]={3.0,3.0,3.0,6.0,7.0,3.0,14.0}
===================================
print:cluster[2][0]={1.0,2.0,3.0,4.0,5.0,11.0,45.0}
print:cluster[2][1]={3.0,4.0,5.0,6.0,7.0,12.0,37.0}
===================================
print:cluster[3][0]={4.0,5.0,6.0,6.0,7.0,0.0,0.0}
print:cluster[3][1]={6.0,4.0,2.0,6.0,7.0,0.0,0.0}
print:cluster[3][2]={4.0,2.0,0.0,6.0,7.0,0.0,0.0}
print:cluster[3][3]={1.0,1.0,1.0,6.0,7.0,0.0,0.0}
print:cluster[3][4]={2.0,1.0,0.0,6.0,7.0,0.0,0.0}
print:cluster[3][5]={2.0,2.0,2.0,6.0,7.0,0.0,0.0}
===================================
/** * 求两点误差平方的方法 * * @param element * 点1 * @param center * 点2 * @return 误差平方 */ private float errorSquare(float[] element, float[] center) { float errSquare=0.0f; for(int i=0;i<element.length;i ){ errSquare =Math.pow((element[i] - center[i]),2); } return errSquare;}
.
├── Kmeans.java
└── 找例子网_Kmeans.zip
0 directories, 2 files
评论